﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Linq;
using System.Xml.Linq;

namespace RFW.Silverlight.Weather
{
	public class Location
	{
		public string FullName { set; get; }
		public string NeighborHood { set; get; }
		public string City { set; get; }
		public string State { set; get; }
		public string Zip { set; get; }
		public string Latitude { set; get; }
		public string Longitude { set; get; }
		public string Elevation { set; get; }

		public override string ToString()
		{
			return this.FullName;
		}

		internal void Process(XDocument doc)
		{
			var data = from o in doc.Descendants("location")
						  select new Location
						  {
							  FullName = o.Element("full").Value,
							  NeighborHood = o.Element("neighborhood").Value,
							  City = o.Element("city").Value,
							  State = o.Element("state").Value,
							  Zip = o.Element("zip").Value,
							  Latitude = o.Element("latitude").Value,
							  Longitude = o.Element("longitude").Value,
							  Elevation = o.Element("elevation").Value
						  };

			foreach (Location o in data)
			{
				this.FullName = o.FullName;
				this.NeighborHood = o.NeighborHood;
				this.City = o.City;
				this.State = o.State;
				this.Zip = o.Zip;
				this.Latitude = o.Latitude;
				this.Longitude = o.Longitude;
				this.Elevation = o.Elevation;
			}
		}
	}
}
